<?php

include('_class/ofc/open-flash-chart.php');

$title = new title("Produit : ".$_POST['Stock_Ref']." - Jusqu'au : ".$_POST['Stock_Date']);
$title->set_style( '{font-size: 12px; color: #778877}' );

$bar = new bar();
if ($data['Quantite'] > $data2['Stock'])
 $bar->set_colour("ff0000");
else
  $bar->set_colour("00ff00");
$bar->set_values( array(intval($data['Quantite'])) );
$bar->set_tooltip("Besoin : ".$data['Quantite']);

$bar2 = new bar();
$bar2->set_colour("0000ff");
$bar2->set_values( array(intval($data2['Stock'])) );
$bar2->set_tooltip("Stock : ".$data2['Stock']);

$abs_y = new y_axis_base();
if ($data['Quantite'] > $data2['Stock'])
 $abs_y->set_range(0, $data['Quantite']+50, 30);
else
 $abs_y->set_range(0, $data2['Stock']+50, 30);

$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->set_y_axis($abs_y);
$y_legend = new y_legend( "Quantite" );
$y_legend->set_style( '{font-size: 15px; color: #778877}' );
$chart->set_y_legend( $y_legend );

$chart->add_element( $bar );
$chart->add_element( $bar2 );
                    
?>

<script type="text/javascript" src="_js/json/json2.js"></script>
<script type="text/javascript" src="_js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "300", "300", "9.0.0");
</script>
<script type="text/javascript">
function open_flash_chart_data()
{
    return JSON.stringify(data);
}

function findSWF(movieName) {
  if (navigator.appName.indexOf("Microsoft")!= -1) {
    return window[movieName];
  } else {
    return document[movieName];
  }
}
var data = <?php echo $chart->toPrettyString(); ?>;

</script>
</head>
<body>
<center>
 <div id="my_chart"></div>
</center>
</body>
</html>